home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SOUNDC.ARJ / DEMO_C.C next >
C/C++ Source or Header  |  1992-07-10  |  2KB  |  79 lines

  1. /* Interrupt drive sound demo
  2.  *
  3.  * Last change:  10 Jul 92  JMG
  4.  *
  5.  * Written by:
  6.  *
  7.  *   Nels Anderson
  8.  *   92 Bishop Drive
  9.  *   Framingham, MA  01701
  10.  *
  11.  * Translated to (Borland) C by:
  12.  *
  13.  *   John Gallant
  14.  *   1249 Cedar Creek Circle
  15.  *   Dayton OH 45459
  16.  *
  17.  * Released to the public domain
  18.  */
  19.  
  20.  
  21. #include <stdio.h>
  22. #include <dos.h>
  23. #include <conio.h>
  24. #include "sounder.h"
  25. #include "sounds.h"
  26.  
  27. void main()
  28. {
  29.   puts("\nSound Interrupt Demo 2");
  30.  
  31.   InitSound();                /* initialize sound parameters */
  32.   Int1CSave = getvect(INTR);        /* save original interrupt vector */
  33.   setvect(0x1C, New1CInt);        /* install sound interrupt */
  34.  
  35.   puts("Rudigore  (press any key to change)");
  36.   StartSound(Ruddigore,99,1);        /* start theme song */
  37.  
  38.   getch();                /* song plays until key pressed */
  39.  
  40.   puts("Canon  (press any key to stop)");
  41.   StartSound(Canon,99,1);
  42.  
  43.   getch();
  44.   MakeSound = FALSE;            /* stop old sound */
  45.   nosound();
  46.   puts("sound stopped...press key to start next sound");
  47.   getch();
  48.  
  49.   puts("sound started again\nscale -- regular tempo");
  50.   StartSound(Scale,1,1);
  51.   while (MakeSound)            /* wait for end */
  52.     ;
  53.   if (MakeSound == FALSE)        /* wait for finish */
  54.   puts("scale -- slower tempo");
  55.   StartSound(Scale,1,2);
  56.  
  57.   while (MakeSound == FALSE)        /* wait for start */
  58.     ;
  59.  
  60.   while (MakeSound)            /* wait for end */
  61.     ;
  62.  
  63.   puts("3 second delay");
  64.  
  65.   MyClock = 0;                /* reset timer */
  66.   while (MyClock < 55)
  67.     ;
  68.  
  69.   puts("times up!!");
  70.   if (MakeSound == FALSE)        /* wait for finish */
  71.     StartSound(WhistleSound,4,1);
  72.   puts("press any key to quit");
  73.  
  74.   getch();
  75.  
  76.   setvect(0x1C, Int1CSave);        /* fix interrupt vector */
  77.   nosound();                /* ensure sound is now off */
  78. }  /* main() */
  79.